//返回Ext元素
function $i(id) {
	return Ext.getCmp(id);
}

//日志记录
function ConsoleLog(log){
	if(config.consolelog)
		console.log(log);
}


/*加载首页内容*/
function LoadingHomeContent(){
	JsopHomeAdv();
}


/*获取首页广告*/
function JsopHomeAdv() {
	if (!HomeAdvLoaded) {
		Ext.data.JsonP.request({
			url: config.url + 'home_adv.php',
			timeout: 10000,
			success: function(response) {
				HomeAdvList = response.result;
				$i('imgLoaded').setSrc('resources/images/loaded1.png');
				JsopHomeMovie(1);
			},
			failure: function() {
				Ext.Msg.alert('', '您当前的网络不好，请检查', function(){navigator.app.exitApp();});
			}
		});
	}
}


/*获取首页视频*/
function JsopHomeMovie(sortid) {
	if(sortid!=1 && sortid!=2 && sortid!=3 && sortid!=4){
		HistoryPanel = 'pnlHome';
		CurrentPanel = 'pnlHome';
		$i("pnlLoading").setActiveItem($i('mainPanel'));
		return;
	}
	if (HomeMovieList[sortid-1].length === 0) {
		Ext.data.JsonP.request({
			url: config.url + 'home_movie.php',
			timeout: 4000,
			params: {
				'sortid': sortid
			},
			success: function(response) {
				HomeMovieList[sortid-1] = response.result;
				$i('imgLoaded').setSrc('resources/images/loaded'+(sortid+1)+'.png');
				JsopHomeMovie(sortid+1);
			},
			failure: function() {
				JsopHomeMovie(sortid+1);
			}
		});
	}
}